﻿@model IEnumerable<Barry.BarbeSystem.Models.Member>
@{
    ViewBag.Title = "Index";
}
@section header{
    <script type="text/javascript">
        $(document).ready(function() {
            var pager = $('#dg').datagrid('getPager'); // get the pager of datagrid
            pager.pagination({ showPageList: false });

        });

        function doSearch() {
            $("#dg").datagrid('load', {
                cardId: $("#card_id").val(),
                name: $("#name").val()
            });
        }
        function recharge() {
            var row = $('#dg').datagrid('getSelected');
            if (row) {
                window.location.href = "/member/recharge/" + row.Id;
            } else {
                $.messager.show({
                    title: '提示',
                    msg: "请选择行"
                });
            }
        }
        function updateUser() {
            var row = $('#dg').datagrid('getSelected');
            if (row) {
                window.location.href = "/member/edit/" + row.Id;
            } else {
                $.messager.show({
                    title: '提示',
                    msg: "请选择行"
                });
            }
        }
        

        function checkOut() {
            var row = $('#dg').datagrid('getSelected');
            if (row) {
                window.location.href = "/member/checkout/" + row.Id;
            } else {
                $.messager.show({
                    title: '提示',
                    msg: "请选择行"
                });
            }
        }


        function destroyUser() {
            var row = $('#dg').datagrid('getSelected');
            if (row) {
                $.messager.confirm('Confirm', '你确定删除此用户吗?', function(r) {
                    if (r) {
                        $.post('/member/Delete', { id: row.Id }, function(result) {
                            if (result.success) {
                                $('#dg').datagrid('reload'); // reload the user data  
                            } else {
                                $.messager.show({
                                    title: '提示',
                                    msg: "删除失败！"
                                });
                            }
                        }, 'json');
                    }
                });
            }
        }

    </script>
}
<div id="tb" style="padding: 5px; height: auto">
    <div class="actionButton">
        @Html.ActionLink(" 新 建 ", "Create", null, new { @class = "easyui-linkbutton", @plain = "true", @iconcls = "icon-add" })
        <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-edit" plain="true"
           onclick=" recharge() ">充值</a> 
          <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-edit" plain="true"
           onclick=" checkOut() ">结账</a> 
        
        
        <a href="javascript:void(0)" class="easyui-linkbutton"
                                            iconcls="icon-edit" plain="true" onclick=" updateUser() ">修改用户信息</a> <a href="javascript:void(0)"
                                                                                                                    class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick=" destroyUser() ">
                                                                                                                     删除用户</a>
    </div>
    <div>
        卡号:
        <input class="" style="width: 80px" id="card_id">
        姓名：<input type="text" id="name" style="width: 80px;" />
        <a href="#" class="easyui-linkbutton" iconcls="icon-search" onclick=" doSearch() ">Search</a>
    </div>
</div>


<table id="dg" data-options="rownumbers:true,singleSelect:true,pagination:true" title="会员信息列表"
    class="easyui-datagrid" url="/member/pageindex" toolbar="#tb">
    <thead>
        <tr>
            <th field="CardId" data-options="width:100">
                @Html.DisplayNameFor(model => model.CardId)
            </th>
            <th field="Name" data-options="width:100">
                @Html.DisplayNameFor(model => model.Name)
            </th>
            <th field="PhoneNumber" data-options="width:100">
                @Html.DisplayNameFor(model => model.PhoneNumber)
            </th>
            <th field="Balance" data-options="width:100">
                @Html.DisplayNameFor(model => model.Balance)
            </th>
            <th field="Discount" data-options="width:100">
                @Html.DisplayNameFor(model => model.Discount)
            </th>
            <th field="Remarks" data-options="width:200">
                @Html.DisplayNameFor(model => model.Remarks)
            </th>
        </tr>
    </thead>
    <tbody>
        @*  @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.PhoneNumber)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Balance)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Discount)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Remarks)
                </td>
                <td>
                    @Html.ActionLink("编辑", "Edit", new { id = item.Id }) |
                
                    @Html.ActionLink("删除", "Delete", new { id = item.Id })
                </td>
            </tr>
        }*@
    </tbody>
</table>
